<!DOCTYPE html>
<html>

<head lang="en">
    <title>首页</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="js/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/reset.css" rel="stylesheet">
    <link rel="stylesheet" href="/css/index.css" rel="stylesheet">


    <script>

        $(function () {
            showComments();
            $("#ipage").attr("src", "/mine/simpleProfiles.html?" + new Date().getTime());


            $.get("/strategyComments",{state:1},function (data) {
                $("#comments").renderValues({list:data},{
                    getHref:function (item,value) {
                        $(item).attr("href", $(item).data("href") + value)
                    }
                });
            })


        });

        function showComments() {
            var Mar = document.getElementsByClassName("Marquee")[0];
            var child_div = Mar.getElementsByTagName("div");
            var picH = 50;//移动高度
            var scrollstep = 3;//移动步幅,越大越快
            var scrolltime = 20;//移动频度(毫秒)越大越慢
            var stoptime = 3000;//间断时间(毫秒)
            var tmpH = 0;
            Mar.innerHTML += Mar.innerHTML;

            function start() {
                if (tmpH < picH) {
                    tmpH += scrollstep;
                    if (tmpH > picH) tmpH = picH;
                    Mar.scrollTop = tmpH;
                    setTimeout(start, scrolltime);
                } else {
                    tmpH = 0;
                    Mar.appendChild(child_div[0]);
                    Mar.scrollTop = 0;
                    setTimeout(start, stoptime);
                }
            }



            setTimeout(start, stoptime)
        }
    </script>



</head>


<body>

<div class="body">
    <input type="checkbox" id="menu">

    <label for="menu" class="menu">
        <span><i class="fa fa-user fa-fw fa-2x"></i></span>
        <span><i class="fa fa-chevron-left fa-fw fa-2x" style="color: #3E3C3B"></i></span>
    </label>

    <!-- 侧边栏 -->
    <div class="nav">
        <iframe id="ipage" frameborder="0" width="90%"></iframe>
    </div>

    <div class="search-head" style="position: relative">
        <div class="row nav-search">
            <div class="col-1"></div>
            <div class="col-10">
                <div class="input-group-sm search">
                    <input class="form-control"  placeholder="搜索:攻略,游记,日报,用户" name="keyword">
                </div>
            </div>
            <a id="keyword" data-href="/query.html?keyword=">
            <i class="fa fa-search" id="select"
               style="color:white;font-size:25px;position: absolute;top: 23%;left: 88%"></i></a>
        </div>
    </div>

    <div class="container">
        <h6 class="module-title">每周推荐</h6>
        <div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
            <div id="travelsCommends">
                <div class="carousel-inner" render-loop="list">
                    <div class="carousel-item item">
                        <a data-href="/travelContent.html?id=" render-key="list.t_id" render-fun="getUrl">
                            <img class="d-block w-100" render-src="list.coverUrl" width="100%" height="200px">
                            <span class="recommend" render-html="list.tc_title"></span></a>
                        <div class="recommend-author"><a data-href="/userProfiles.html?id=" render-key="list.author_id" render-fun="getUrl">
                            <img class="rounded-circle" style="width: 10%;" render-src="list.author_headImgUrl">
                            <span render-html="list.author_nickName"></span>
                        </a>在&nbsp;
                            <span render-html="list.r_name"></span>
                        </div>
                    </div>
                </div>
            </div>
            <a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
                <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                <span class="sr-only"></span>
            </a>
            <a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
                <span class="carousel-control-next-icon" aria-hidden="true"></span>
                <span class="sr-only"></span>
            </a>
        </div>
        <hr>
        <div>
        <div class="row nav-box">
            <div class="col-3" align="center">
                <a href="strategyPage.html"><img src="/img/find.jpg" width="100%"><span
                        style="color: #ff9d00 ;font-size:68%">找攻略</span></a>
            </div>
            <div class="col-3" align="center">
                <a href="travelPage.html"><img src="/img/look.jpg" width="100%"><span
                        style="color: #feca2b;font-size: 68%">看游记</span></a>
            </div>
            <div class="col-3" align="center">
                <a href="shop/index.html"><img src="/img/shop.jpg" width="100%"><span
                        style="color: #fd4e4e;font-size: 68%">商城</span></a>
            </div>
            <div class="col-3" align="center">
                <a href="question.html"><img src="/img/ask.jpg" width="100%"><span
                        style="color: #42d6ba;font-size: 68%">问达人</span></a>
            </div>
            <div class="col-3" align="center">
                <a href="hotel.html"><img src="/img/hotel.jpg" width="100%"><span
                        style="color: #42d6ba;font-size: 68%">订酒店</span></a>
            </div>
        </div>
        </div>

        <div class="row dynamic " id="comments">

            <div class="col-1" style="padding: 0px;">
                <img class="rounded" src="/img/topComment.png" style="width: 50px;">
            </div>

            <div class="col">
                <div class="Marquee" render-loop="list">
                    <div class="d-flex">
                        <a data-href="/userProfiles.html?id=" render-key="list.user.id" render-fun="getHref">
                            <img class="rounded-circle dynamic-head"
                                 render-src="list.user.headImgUrl">
                        </a>
                        <a data-href="/strategyComment.html?id=" class="dynamic-detail" render-key="list.id" render-fun="getHref">
                            <span render-html="list.user.nickName"></span>点评了攻略<p render-html="list.strategy.title"></p>
                        </a>
                    </div>
                </div>

            </div>
        </div>
    </div>

    <hr>
    <div class="container">
        <h6 class="module-title" >骡窝日报 <a href="newsPage.html">更多</a></h6>
        <div class="news " id="bigger">
            <a data-href="newsContent.html?id=" render-key="id" render-fun="getUrl">
                <img width="100%" render-src="coverUrl">
                <div class="caption">
                    <h5 render-html="title"></h5>
                    <p render-html="subtitle"></p>
                    <span class="fl-r">
						浏览量:<b render-html="num"></b>&nbsp;&nbsp;&nbsp;&nbsp;By:骡窝窝
					</span>
                </div>
            </a>
        </div>
    </div>

        <div class="mysmaller">
            <div>
                <hr/>
                    <div id="smaller" render-loop="list">
                        <div style="margin-bottom: 20px">
                            <a data-href="newsContent.html?id=" render-key="list.id" render-fun="getUrl">
                                <div class="row news-detail">
                                    <div class="col-5">
                                        <img render-src="list.coverUrl">
                                    </div>
                                    <div class="col-7">
                                        <h4 render-html="list.title"></h4>
                                        <p render-html="list.subtitle"></p>
                                        <span class="fl-r">
                                            浏览量&nbsp;&nbsp;<b render-html="list.num"></b>&nbsp;&nbsp;&nbsp;&nbsp;By:骡窝窝
                                        </span>
                                    </div>
                                </div>
                            </a>
                        </div>
                    </div>
                 <hr/>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {

        var store = [];
        $.get("/travelCommends", {"type": "2"}, function (data) {
            $("#travelsCommends").renderValues(data, {
                getUrl: function (item, value) {
                    $(item).attr("href", $(item).data("href") + value)
                }
            });
            $(".carousel-item:first").addClass("active");
        });



        $.get("/dailies", {"pageSize": "10"}, function (data) {
            store = data.list;
            //存放的容器,也是一个数组
            var first=  store.splice(0,1);
            $("#bigger").renderValues(first[0],{
                getUrl: function (item,value) {
                    $(item).attr("href", $(item).data("href") + value)
                }
            });
            $(".mysmaller").renderValues({list:store},{
                getUrl: function (item,value) {
                    $(item).attr("href", $(item).data("href") + value)
                }
            });
        });
        //跳转至查询页面
        $("#keyword").click(function () {
            window.location.href = $(this).attr("href",$(this).data("href")+$("input[name='keyword']").val());
        });
    })

</script>





</body>

</html>